<?php
namespace haibao\cms\business\control;

use haibao\frame\data\query\Condition;
use haibao\cms\business\control\ArticleController;
use haibao\cms\model\filter\Article as ArticleFilter;
use haibao\cms\model\filter\ArticleTag as ArticleTagFilter;
use haibao\cms\model\filter\ArticleProImage as ArticleProImageFilter;
use haibao\cms\model\filter\imagecollective\ImageCollective as ImageCollFilter;
use haibao\cms\model\filter\imagecollective\ImageCollectiveTag as ImageCollTagFilter;
use haibao\cms\model\filter\imagecollective\ImageCollectivePro as ImageCollProFilter;
use haibao\cms\model\filter\FeaturePublish as FeaturePublishFilter;
use haibao\cms\model\filter\FeatureTag as FeatureTagFilter;
use haibao\cms\model\filter\Video as VideoFilter;
use haibao\cms\model\filter\ImageLibrary as ImageLibraryFilter;
use haibao\cms\web\view\app\article\Preview;
use haibao\frame\Environment;

class Base extends \haibao\frame\http\UserControl{

	const CUT_TITLE_LEN = 24;
	const CUT_SHORT_TITLE_LEN = 12;
	const DATA_TYPE_ARTICLE = 1;
	const DATA_TYPE_IMAGE_SET = 2;
	const DATA_TYPE_FEATURE = 3;
	const DATA_TYPE_VIDEO = 4;
	const DATA_TYPE_IMAGE_LIBRARY = 8;
	const DATA_TYPE_IMAGE_EXCLUSIVE = 9;
	
	const PARAMETER_TYPE =6;//链接地址跳转中间页，做点击统计
	const SKIP_TYPE_ARTICLE = 2;//app焦点图选择html或文章id

	const DEFAULT_SHOW_IMAGE_URL = 'http://c1.haibao.cn/images/article_default_02.jpg';

	const PACKAGE_DATA_TYPE_INDEX_TREND_OR_STAR = 1;
	const PACKAGE_DATA_TYPE_INDEX_BRAND_OR_BEAUTY_OR_LIFT = 2;
	
	public static $CONTROL_DATA = 'controlData';
	public static $CONTROL_CONTENT = 'content';
	public static $CURRENTPAGE = 'currentPage';
	public static $PAGEABLE = 'pageable';
	public static $SITE_TEMPLATE_ID = 'siteTemplateId';
	public static $SITE_CHANNEL_TAG = 'siteChannelTag';
	public static $FILE_NAME = 'fileName';
	public static $TAG_INFO = 'tagInfo';
	public static $CHANNEL_ID = 'channelId';
	/**
	 * 模版的更新时间
	 */
	public $updateTime;
	public $controlId;
	public $isPublish;
	public $conditionTagId = 0;//用于查询的标签ID
	public $topTagId = 6;//顶级标签ID
	public $tagUrl = '';
	public $tagIds = 340;
	public $packageArr = array();
	public $packageKey = '';
	public $packageArrCount = 0;
	public $articleAction;
	public $imageCollectiveAction;
	public $wapInfoAction;
		
	public function __construct($updateTime='',$controlId='',$isPublish=''){
		$data = new \haibao\cms\data\site\Site();
		$this->setConfig( 'default' );
		$this->updateTime = strtotime($updateTime);
		$this->controlId = $controlId;
		$this->isPublish = $isPublish;
		if($this->isPublish){
			$this->setConfig('controlPublish');
		}else{
			$this->setConfig('controlPreview');
		}
	}
	
	/**
	 * 生成HTML路径
	 * @param : String $className
	 * @param : String $md5Key 生成MD5附加参数
	 */
	public function generateHtmlPath($className,$md5Add = ''){

		//file_put_contents(\haibao\frame\Environment::path().'/web/logs/control.log', '当前进行:'.$className."\n",FILE_APPEND);
		$basePath = md5($this->controlId.$className.$md5Add).'.html';
		return str_replace(array('/', '\\'), '/', $basePath);
	}

	/**
	 * 生成html
	 * @param string $path 路径
	 * @param string $content 内容
	 */
	public function generateHtml($path,$content = ''){

		$savePath = $this->getSaveHtmlPath();
		$savePath = $savePath.$path;
		if($this->isPublish){
			file_put_contents($savePath, $content);
		}else{
			
			//if(!file_exists($savePath) || (filemtime($savePath) < $this->updateTime) ){
			if(!file_exists($savePath)){
				file_put_contents($savePath, $content);
			}
		}
	}
	
	public function getControlParameters($controlData){
		$parameters = array();
		if($controlData['auto']){
			$temp = array();
			$fieldName = '';
			foreach($controlData['auto'] as $data){
				if(empty($fieldName) && $data['ControlId']){
					$fieldName = $this->getControlInfoStatisticsName($data['ControlId']);
				}
				$parameterValue = json_decode($data['ParameterValue']);
				
				$parameterValue->PicUrl = '';
				$parameterValue->AppArticleId = '';
				if(!empty($parameterValue->SkipType) && $parameterValue->SkipType == self::SKIP_TYPE_ARTICLE){
					$articleId = $parameterValue->SkipData;
					$parameterValue->SkipData = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_WAP)."/appstar/articlem/".$articleId.".htm?wv=1";
					$parameterValue->PicUrl = $this->getArticleImage($articleId);
					$parameterValue->AppArticleId = $articleId;
				}
				foreach ($parameterValue as $key=>$val){
					if($key == $fieldName){
						$parameterValue->$key = $this->getSkipUrl($data['Id'],$val);
					}
					if(!isset($val)){
						$parameterValue->$key = '';
					}
				}
		
				array_push($parameters,$parameterValue);
			}
		}
		
		return $parameters;
	}
	
	public function getControlInfoStatisticsName($controlId){
		$fieldName = '';
		$data = new \haibao\cms\data\PageControl();
		$controlInfo =  $data->getOneById($controlId);
		if(!empty($controlInfo) && !empty($controlInfo->Parameter)){
			$parameterValue = json_decode($controlInfo->Parameter);
			foreach ($parameterValue as $key=>$parameterVal){
				if($parameterVal->parameterType == self::PARAMETER_TYPE){
					$fieldName = $key;
					break;
				}
			}
		}
		
		return $fieldName;
	}

	public function getSkipUrl($id,$url){
		return \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_WAP).'/skip.html?type=2&id='.$id.'&to='.urlencode($url);
	}

	/**
	 * 获取HTML保存路径
	 */
	private function getSaveHtmlPath(){
		if($this->isPublish){
			$path = \haibao\frame\Environment::path().\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CONTROL_HTML_PUBLISH_PATH);
		}else{
			$path = \haibao\frame\Environment::path().\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CONTROL_HTML_PREVIEW_PATH);
		}
		if(!file_exists($path)){
			mkdir($path, 750, true);
		}
		return $path;
		
	}
	
	/**
	 * 创建文件保存路径
	 */
	private function createDir($path){
		return is_writable($path['dirname']) ?: mkdir($path['dirname'], 750, true);
	}
	
	public function replaceCDNLink($content,$flag = false){
		return preg_replace_callback("/<img\s?(data\-lazy\-src|src)=\"((?!http|https).*?)\" width=\"(\d+)\" (height=\"(\d+)\")?.*?>/is", 'self::regReplaceUrl', $content);
	}
	
	/**
	 * 替换内容中的img 为mt* 正则使用
	 */
	public function regReplaceUrl($matches){
		$imgHtml = '';
		$key = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_IMG_ENCRYPT_KEY);
		if(count($matches) == 6){
			$height = array_pop($matches);
			array_pop($matches);
		}else{
			$height = 0;
		}
		$width = array_pop($matches);
		$imageUrl = array_pop($matches);
		array_pop($matches);
		$imgHtml = array_pop($matches);
		
		if($width && $imageUrl && $imgHtml){

			$staticImageUrl = $this->replaceImageLink($imageUrl,$width,$height);

			if(\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_DEFAULT)){
				$newImgName = md5($staticImageUrl.$key);
				$hasCount = strpos($staticImageUrl, \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img');
			
				$cdnNum = self::getHash($newImgName);
				$cdnHost = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_HOST);
				$imgUrl = $cdnHost[$cdnNum];
				
				$mtUrl = str_replace(\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img',$imgUrl,$staticImageUrl);
				return strtr($imgHtml,array($imageUrl=>$mtUrl));
			
			}else{
				return strtr($imgHtml,array($imageUrl=>$staticImageUrl));
			}
		}else{
			return $imgHtml;
		}
	}
	
	/**
	 * 图片替换成static的链接 正则使用
	 * @param string $imgUrl
	 * @param int $width	宽 600(文章图片最大为600)
	 * @param int $height	高
	 * @param int $quality	质量(0-100)，默认75
	 * @param int $water	是否水印(1打0无)
	 * @return string
	 */
	protected function replaceImageLink($imgUrl,$width = 600,$height = 0,$quality = 100,$water = 0){
		$key = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_IMG_ENCRYPT_KEY);
		$imgFileName = substr($imgUrl, strrpos($imgUrl, '/')+1);
		$imgName = substr($imgFileName, 0, strrpos($imgFileName, '.'));
		$imgType = substr($imgFileName, strrpos($imgFileName, '.'));
		$condition = '/'.$width.'_'.$height.'_'.$quality.'_'.$water.'/'.$imgName.'/';
		$newUrl = '';
		$isHasUploads = strpos($imgUrl, \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::IMAGE_UPLOAD_BASE_PATH));
		if($isHasUploads === false){
			$config = \haibao\cms\Config::getFrameConfig();
			$newImgName = str_replace($config[\haibao\frame\http\HttpEnvironment::DOMAIN], '', trim($imgUrl,'/'));
			$newUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img'.$condition.$newImgName;
		} else {
			$newImgName = md5($condition.$key);
			$newUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img'.$condition.$newImgName.$imgType;
		}
		return $newUrl;
	}
	
	public static function getImageLink($imgUrl,$width = 600,$height = 0,$quality = 100,$water = 0,$isMt = true){
		$key = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_IMG_ENCRYPT_KEY);
		$imgFileName = substr($imgUrl, strrpos($imgUrl, '/')+1);
		$imgName = substr($imgFileName, 0, strrpos($imgFileName, '.'));
		$imgType = substr($imgFileName, strrpos($imgFileName, '.'));
		$condition = '/'.$width.'_'.$height.'_'.$quality.'_'.$water.'/'.$imgName.'/';
		$newUrl = '';
		$isHasUploads = strpos($imgUrl,\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::IMAGE_UPLOAD_BASE_PATH));
		if($isHasUploads === false){
			$newUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img'.$condition.$imgUrl;
		} else {
			$newImgName = md5($condition.$key);
			$newUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img'.$condition.$newImgName.$imgType;
		}
		
        if(\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_DEFAULT) && $isMt){
			$newImgName = md5($newUrl.$key);
			$hasCount = strpos($newUrl, \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN));
				
			$cdnNum = self::getHash($newImgName);
			$cdnHost = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_HOST);
			$imgUrl = $cdnHost[$cdnNum];
			$newUrl = str_replace(\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN).'/img',$imgUrl,$newUrl);
				
		}
		return $newUrl;
	}
	/**
	 * 按照固定长度切割内容
	 * @param : String $title 被切割内容
	 * @param : $len 切割长度
	 */
	public function cutTitle($title,$cutLen,$isReturn = false){
		$titleLen = mb_strlen($title,'utf-8');
		$final = '';
		$len = 1;
		if($titleLen > $cutLen){
			$title = mb_substr($title,0,$cutLen,'utf-8');
			if($isReturn){
			    $title = $title.'...';
			}
		}
		return $title;
	}
	
	/**
	 * 时间格式化
	 * @param : $date 时间（Y-m-d H:i:s）
	 * @param : $type 格式化结果 1（今天/昨天 10:25）
	 */
	public static function formatDate($date,$type = 1){
		$finalDate = '';
		$strTime = strtotime($date);
		$today = date('j');
		$nowMonth = date('Ym');
		if($type == 1){
			$day = date('j',$strTime);
			$hour = date('H:i',$strTime);
			$month = date('Ym',$strTime);
			$diff = $today - $day;
			if($diff == 0 && $month == $nowMonth){
				$finalDate = '今天'.$hour;
			}elseif($diff == 1 && $month == $nowMonth){
				$finalDate = '昨天'.$hour;
			}else{
				$finalDate = date('Y-m-d',$strTime);
			}
		}
		return $finalDate;
	}
	
	/**
	 * 获取文章标签
	 * @param : Array $articleId 
	 * @param : Boolure $isPrimary  是否只返回主标签
	 */
	public function getArticleTag($articleId,$isPrimary = true){
		
		$articleTagFilter = new ArticleTagFilter();

		$articleTagFilter->select(
				array(
					ArticleTagFilter::CONDITION_FIELD_NAME_ARTICLE_ID,
					ArticleTagFilter::CONDITION_FIELD_NAME_TAG_ID,
					ArticleTagFilter::CONDITION_FIELD_NAME_PARENT_ID,
					ArticleTagFilter::CONDITION_FIELD_NAME_IS_PRIMAIY,
				)
		);
		if($isPrimary) {
			$articleTagFilter->where(ArticleTagFilter::CONDITION_FIELD_NAME_IS_PRIMAIY,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Article::PUBLISHED_YES);
		}
		$articleTagFilter->where(ArticleTagFilter::CONDITION_FIELD_NAME_ARTICLE_ID,Condition::CONDITION_IN,$articleId);

		$article = new \haibao\cms\data\Article();
		$articleTag = $article->getAll($articleTagFilter);
		$articleTagArr = array();
		foreach($articleTag as $key=>$tag){
			
			if(isset($articleTagArr[$tag->ArticleId])) {
				$articleTagArr[$tag->ArticleId][] = $tag->TagId;
			}else{
				$articleTagArr[$tag->ArticleId] = array();
				$articleTagArr[$tag->ArticleId][] = $tag->TagId;
			}
		}
		if($isPrimary){
			$arr = array();
			foreach ($articleTagArr as $key=>$value) {
				$arr[$key] = array_pop($value);
			}
			return $arr;
		}
		return $articleTagArr;
	}
	
	/**
	 * 初始化文章公共控制器
	 * @return \haibao\cms\business\control\ArticleController
	 */
	public function initArticleControl(){

		return ArticleController::initArticleControl();
	}
	/**
	 * 
	 */
	/**
	 * 获取文章返回信息
	 * @param Int $queryType 查询的类型
	 */
	public function getArticleControl($queryType,$queryCondition){
		$articleControl = ArticleController::initArticleControl();
		$articleControl->setSource($queryCondition['source']);
		$articleControl->initParam();
		if($queryType !=4){
			list($isPrimaryTag,$isReturnTag,$isParentTag,$isConditionTag,$isReturnPrimary) = $this->packQueryCondition($queryCondition);
		}
		switch($queryType){
			case ArticleController::QUERY_TYPE_CHANNEL:
				
				$articleControl->setLimit($queryCondition['limit']);
				$articleControl->setLevel($queryCondition['level']);
				if(empty($queryCondition['biglevel'])){
					$queryCondition['biglevel'] = 6;
				}
				$articleControl->setBigLevel($queryCondition['biglevel']);
				if(isset($queryCondition['isImageColl'])) {
					$articleControl->setIsImageColl($queryCondition['isImageColl']);
				}
				$articleControl->setIsArticleTag($queryCondition['isTag'],$this->conditionTagId,$isPrimaryTag,$isReturnTag,$isParentTag,$isConditionTag,$isReturnPrimary);
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}
				if(isset($queryCondition['isPage'])) $articleControl->setIsPage($queryCondition['isPage']);
				if(isset($queryCondition['currentPage'])) $articleControl->setCurrentPage($queryCondition['currentPage']);

				if(isset($queryCondition['primaryTag'])) $articleControl->setPrimaryTag($queryCondition['primaryTag']);
				if(isset($queryCondition['isDate']) && $queryCondition['isDate']){
				    $articleControl->setIsDate($queryCondition['isDate'], $queryCondition['dateType']);
				}
				return $articleControl->getChannelArticleAndAtiasByChannel();
				
				break;
			case ArticleController::QUERY_TYPE_CLICK:
			   
				$articleControl->setLimit($queryCondition['limit']);
				$articleControl->setIsArticleTag($queryCondition['isTag'],$this->conditionTagId,$isPrimaryTag,$isReturnTag,$isParentTag,$isConditionTag);
				if(isset($queryCondition['isImageColl'])) {
				    $articleControl->setIsImageColl($queryCondition['isImageColl']);
				}
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}
				if(isset($queryCondition['biglevel'])) $articleControl->setBigLevel($queryCondition['biglevel']);
				
				if(isset($queryCondition['level'])){
					$articleControl->setLevel($queryCondition['level']);
				}
				if(isset($queryCondition['isDate'])){
					$articleControl->setIsDate($queryCondition['isDate'], $queryCondition['dateType']);
				}
				return $articleControl->getChannelArticleAndAtiasByClick();
				break;
			
			case ArticleController::QUERY_TYPE_BRAND_STAR:
				
				$articleControl->setLimit($queryCondition['limit']);
				$articleControl->setIsArticleTag($queryCondition['isTag'],$this->conditionTagId);
				$articleControl->setRelType($queryCondition['relType']);
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}
				
				return $articleControl->getChannelArticleToBrandOrStar();
				
				break;
			case ArticleController::QUERY_TYPE_IMAGE_COLLECTIVE_CLICK:
				
				if(isset($queryCondition['isDate'])){
					$articleControl->setIsdate($queryCondition['isDate'],$queryCondition['dateType']);
				}
				if(isset($queryCondition['isArticleTag'])){
					$articleControl->setIsArticleTag($queryCondition['isArticleTag'],$this->conditionTagId);
				}
				if(isset($queryCondition['isParentTag'])){
					$articleControl->setIsParentTag($queryCondition['isParentTag']);
				}
				if(isset($queryCondition['orderByNew'])){
					$articleControl->setOrderByNew($queryCondition['orderByNew']);
				}
				if(isset($queryCondition['limit'])){
					$articleControl->setLimit($queryCondition['limit']);
				}
				if(isset($queryCondition['offset'])){
					$articleControl->setOffset($queryCondition['offset']);
				}
				if(isset($queryCondition['level'])){
					$articleControl->setLevel($queryCondition['level']);
				}
				if(isset($queryCondition['biglevel'])){
					$articleControl->setBigLevel($queryCondition['biglevel']);
				}
				$articleControl->setSource($queryCondition['source']);
				
				
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}

				return $articleControl->getImageCollectiveByClick();
				
				break;
			case ArticleController::QUERY_TYPE_LIST_NEW:
				$articleControl->setLimit($queryCondition['limit']);
				$articleControl->setLevel($queryCondition['level']);

				if(isset($queryCondition['isCalendarData'])) {
					$articleControl->setIsCalendarData($queryCondition['isCalendarData']);
				}

				if(isset($queryCondition['biglevel'])) $articleControl->setBigLevel($queryCondition['biglevel']);
				
				$articleControl->setCurrentPage($queryCondition['currentPage']);
				if(isset($queryCondition['isImageColl'])) {
					$articleControl->setIsImageColl($queryCondition['isImageColl']);
				}
				$articleControl->setIsArticleTag($queryCondition['isTag'],$this->conditionTagId,$isPrimaryTag,$isReturnTag,$isParentTag,$isConditionTag,$isReturnPrimary);
				
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}
				return $articleControl->getListByNew();
			case ArticleController::QUERY_TYPE_ARTICLE_IN_TOP_TAG_ID:
			
				$articleControl->setLimit($queryCondition['limit']);
				$articleControl->setLevel($queryCondition['level']);
				
				if(isset($queryCondition['biglevel'])) $articleControl->setBigLevel($queryCondition['biglevel']);
				
				if(isset($queryCondition['isImageColl'])) {
					$articleControl->setIsImageColl($queryCondition['isImageColl']);
				}
				$articleControl->setIsArticleTag($queryCondition['isTag'],$this->conditionTagId,$isPrimaryTag,$isReturnTag,$isParentTag,$isConditionTag);
				
				$articleControl->setHasParentId($queryCondition['hasParentId']);
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}
				return $articleControl->getChannelArticleMustInTopTagId();
			
				break;
			case ArticleController::QUERY_TYPE_WAP_INFO_LIST:
			    
				$articleControl->setLimit($queryCondition['limit']);
			
				$articleControl->setCurrentPage($queryCondition['currentPage']);
				if(isset($queryCondition['isImageColl'])) {
					$articleControl->setIsImageColl($queryCondition['isImageColl']);
				}
				$articleControl->setIsArticleTag($queryCondition['isTag'],$this->conditionTagId);
			
				if($queryCondition['isProImage']){
					$articleControl->setIsProImage($queryCondition['isProImage'],$queryCondition['proImageLevel']);
				}else{
					$articleControl->setIsProImage($queryCondition['isProImage']);
				}
				return $articleControl->getWapInfoList(isset($queryCondition['channelType']) && $queryCondition['channelType']?$queryCondition['channelType']:null);
				break;
			default:
				break;
			
		}
	}
	
	/**
	 * 得到标签对应的频道url
	 * @param unknown_type $topTagId
	 * @return string
	 */
	public static function getTagChannel($topTagId){
		$topTags = self::getTopTags();
		$channelUrl = 'http://www.'.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_TOP_DOMAIN);
		if($topTagId){
			if(isset($topTags[$topTagId])){
				$channelUrl = trim($topTags[$topTagId]['tagchannelurl']);
			}
		}
		
		return $channelUrl;
	}
	
	public static function getTopTags(){
		$domainHost = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_STATIC_DOMAIN);
		if(\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_DEFAULT)){
			$domainHost = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_DOMAIN);
		}
		$hostDomain = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_TOP_DOMAIN);
		return array(
				6 => array('id'=>0,'name'=>'首页','domain'=>'www','channel'=>'www','channelurl'=>'http://www.'.$hostDomain,'tagchannelurl'=>'http://www.'.$hostDomain,'logo'=>$domainHost.'/images/hb_logo.jpg'),
				310 => array('id'=>1,'name'=>'时装','domain'=>'fashion','channel'=>'fashion','channelurl'=>'http://fashion.'.$hostDomain,'tagchannelurl'=>'http://fashion.'.$hostDomain,'logo'=>$domainHost.'/images/fashion_logo.jpg'),
				630 => array('id'=>2,'name'=>'生活','domain'=>'life','channel'=>'diy','channelurl'=>'http://life.'.$hostDomain,'tagchannelurl'=>'http://life.'.$hostDomain,'logo'=>$domainHost.'/images/sh_logo.jpg'),
				1383 => array('id'=>2,'name'=>'明星','domain'=>'star','channel'=>'stars','channelurl'=>'http://star.'.$hostDomain,'tagchannelurl'=>'http://star.'.$hostDomain,'logo'=>$domainHost.'/images/mx_logo.jpg'),
				24 => array('id'=>3,'name'=>'美容','domain'=>'beauty','channel'=>'beauty','channelurl'=>'http://beauty.'.$hostDomain,'tagchannelurl'=>'http://beauty.'.$hostDomain,'logo'=>$domainHost.'/images/mr_logo.jpg'),
				520 => array('id'=>4,'name'=>'生活','domain'=>'life','channel'=>'diy','channelurl'=>'http://life.'.$hostDomain,'tagchannelurl'=>'http://life.'.$hostDomain,'logo'=>$domainHost.'/images/sh_logo.jpg'),
				668 => array('id'=>4,'name'=>'生活','domain'=>'life','channel'=>'diy','channelurl'=>'http://life.'.$hostDomain,'tagchannelurl'=>'http://life.'.$hostDomain,'logo'=>$domainHost.'/images/sh_logo.jpg'),
				1513 => array('id'=>4,'name'=>'生活','domain'=>'life','channel'=>'diy','channelurl'=>'http://life.'.$hostDomain,'tagchannelurl'=>'http://life.'.$hostDomain,'logo'=>$domainHost.'/images/sh_logo.jpg'),
				955 => array('id'=>5,'name'=>'品牌','domain'=>'brand','channel'=>'brands','channelurl'=>'http://brand.'.$hostDomain,'tagchannelurl'=>'http://brand.'.$hostDomain,'logo'=>$domainHost.'/images/pp_logo.jpg'),
				//2848 => array('id'=>5,'name'=>'品牌','domain'=>'brand','channel'=>'brands','channelurl'=>'http://brand.'.$hostDomain,'tagchannelurl'=>'http://brand.'.$hostDomain,'logo'=>$domainHost.'/images/pp_logo.jpg'),
				2848 => array('id'=>5,'name'=>'设计师','domain'=>'brand','channel'=>'designers','channelurl'=>'http://designers.'.$hostDomain,'tagchannelurl'=>'http://www.'.$hostDomain,'logo'=>$domainHost.'/images/pp_logo.jpg'),
				7455 => array('id'=>6,'name'=>'配饰','domain'=>'accessory','channel'=>'accessory','channelurl'=>'http://accessory.'.$hostDomain,'tagchannelurl'=>'http://accessory.'.$hostDomain,'logo'=>$domainHost.'/images/ps_logo.jpg'),
				6863 => array('id'=>7,'name'=>'珠宝腕表','domain'=>'jewelrywatch','channel'=>'jewelrywatch','channelurl'=>'http://jewelrywatch.'.$hostDomain,'tagchannelurl'=>'http://jewelrywatch.'.$hostDomain,'logo'=>$domainHost.'/images/zb_logo.jpg'),
				211 => array('id'=>8,'name'=>'新娘','domain'=>'wedding','channel'=>'wedding','channelurl'=>'http://wedding.'.$hostDomain,'tagchannelurl'=>'http://wedding.'.$hostDomain,'logo'=>$domainHost.'/images/xn_logo.jpg'),
				6545 => array('id'=>9,'name'=>'自媒体','domain'=>'fashionista','channel'=>'fashionista','channelurl'=>'http://fashionista.'.$hostDomain,'tagchannelurl'=>'http://fashionista.'.$hostDomain,'logo'=>$domainHost.'/images/zmt_logo.jpg'),
				11280 => array('id'=>10,'name'=>'美剧','domain'=>'tv','channel'=>'tv','channelurl'=>'http://tv.'.$hostDomain,'tagchannelurl'=>'http://tv.'.$hostDomain,'logo'=>$domainHost.'/images/tv_logo.jpg'),
		);
	}
	
	public static function getFeatureClass(){
	    return array(
	        '潮流'=>\haibao\cms\model\data\FeaturePublish::CLASS_FASHION,
	        '美容'=>\haibao\cms\model\data\FeaturePublish::CLASS_PAINT,
	        '明星'=>\haibao\cms\model\data\FeaturePublish::CLASS_STAR,
	        '时装周'=>\haibao\cms\model\data\FeaturePublish::CLASS_FASHION_WEEK,
	        '品牌'=>\haibao\cms\model\data\FeaturePublish::CLASS_BRAND
	    );
	}
	
	/**
	 * 获取博客分类
	 */
	public static function getBlogCategory(){
		return array(
				91=>array('id'=>91,'name'=>'自媒体精英','level'=>1,'url'=>"http://fashionista.haibao.com/cate/91/0/"),
				92=>array('id'=>92,'name'=>'明星名模','level'=>1,'url'=>"http://fashionista.haibao.com/cate/92/0/"),
				93=>array('id'=>93,'name'=>'时装博主','level'=>1,'url'=>"http://fashionista.haibao.com/cate/93/0/"),
				94=>array('id'=>94,'name'=>'美容博主','level'=>1,'url'=>"http://fashionista.haibao.com/cate/94/0/"),
				95=>array('id'=>95,'name'=>'视觉展','level'=>1,'url'=>"http://fashionista.haibao.com/cate/95/0/"),
				96=>array('id'=>96,'name'=>'摄影师','level'=>2,'url'=>"http://fashionista.haibao.com/cate/96/0/"),
				99=>array('id'=>99,'name'=>'明星','level'=>2,'url'=>"http://fashionista.haibao.com/cate/99/0/"),
				98=>array('id'=>98,'name'=>'海报明星编辑团','level'=>1,'url'=>"http://fashionista.haibao.com/cate/98/0/"),
				100=>array('id'=>100,'name'=>'名模','level'=>2,'url'=>"http://fashionista.haibao.com/cate/100/0/"),
				101=>array('id'=>101,'name'=>'化妆师','level'=>2,'url'=>"http://fashionista.haibao.com/cate/101/0/"),
				102=>array('id'=>102,'name'=>'造型师','level'=>2,'url'=>"http://fashionista.haibao.com/cate/102/0/"),
				103=>array('id'=>103,'name'=>'设计师','level'=>2,'url'=>"http://fashionista.haibao.com/cate/103/0/")
		);
	}
	/**
	 *
	 * @param unknown_type $articleId 文章ID
	 * @param unknown_type $topTagId 频道ID
	 * @param unknown_type $artcleType 文章类型0文章1图片
	 * @return void|string
	 */
	public static function getArticleUrl($articleId,$topTagId = 6,$artcleType = ArticleController::INFO_TYPE_ARTICLE){
		if (!$articleId) { 
			return '';
		}
		$topTags = self::getTopTags();
		$articleDomain = 'http://www.'.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_TOP_DOMAIN);
		$domainName = 'www';
		if($topTagId){
			if(isset($topTags[$topTagId])){
				$articleDomain = trim($topTags[$topTagId]['channelurl']);
				$domainName = trim($topTags[$topTagId]['domain']);
			}
		}
		$articleUrl = '';
		if($artcleType == ArticleController::INFO_TYPE_ARTICLE){
			$articleUrl = $articleDomain.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::NEW_ARTICLE_VIEW_NAME).$articleId.'.htm';
		}else if($artcleType == ArticleController::INFO_TYPE_IMAGE){
			$articleUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_PIC).'/'.$domainName.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::IMAGE_VIEW_NAME).$articleId.'.htm';
		}else if($artcleType == ArticleController::INFO_TYPE_ARTICLE_PIC){
			$articleUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_PIC).'/'.$domainName.'/'.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::ARTICLE_VIEW_NAME).'/'.$articleId.'.htm';
		}
		return $articleUrl;
	}
	
	
	
	public static function getTagUrl($tagUrl,$tagType,$topTagId = 6,$tagId = 0){
		//8411造型日历
		$relTagUrl = '';
		if($tagId == 8411){
			$relTagUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_CALENDAR);
		} else {
			$topTags = self::getTopTags();
			$articleDomain = 'http://www.'.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_TOP_DOMAIN);
			if($topTagId){
				if(is_array($topTagId)){
					$topTagId = array_shift($topTagId);
				}
				if(isset($topTags[$topTagId])){
					if(in_array($tagType, array(\haibao\cms\model\data\Tag::TYPE_BRAND,\haibao\cms\model\data\Tag::TYPE_STAR,\haibao\cms\model\data\Tag::TYPE_DESIGNER,\haibao\cms\model\data\Tag::TYPE_TV))) {
						$articleDomain = 'http://'.trim($topTags[$topTagId]['channel']).'.'.\haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_TOP_DOMAIN);
					} else {
						if(!empty($tagUrl)){
							if(!preg_match('/\/(.*?)\/(\d+)\//i',$tagUrl,$match)){
								$replacement = '/${1}/'.$tagId.'/';
								$tagUrl = preg_replace('/\/(.*?)\/(.*)/i', $replacement, $tagUrl);
							}
						} else {
							if($topTagId == 6){//无结构标签
								$tagUrl = '/zhuanti/'.$tagId.'/';
							} else {
								$tagUrl = '/'.trim($topTags[$topTagId]['channel']).'/'.$tagId.'/';
							}
						}
						
						$articleDomain = trim($topTags[$topTagId]['tagchannelurl']);
						
					}
				}
			}
			$relTagUrl = $articleDomain.$tagUrl;
		}
	    return $relTagUrl;
	}
	
	/**
	 * 得图集页面的标签URL，跳转到图片标签列表页
	 * @param unknown_type $tagId
	 * @return string
	 */
	public static function getPicTagUrlByTagId($tagId){
		$tagUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_PIC).'/piclists/'.$tagId.'/';
		return $tagUrl;
	}
	
	/**
	 * 文章和图集数据合并 返回固定几条
	 * @param Array $articles 文章
	 * @param Array $imageColls 图集
	 */
	public function mergeData($articles,$imageColls,$returnCount = 5){
		$mergeArr = array();
		if($imageColls){
			foreach($articles as $key=>$article){
				$mergeArr[$key] = $article;
			}
			foreach($imageColls as $key=>$imageColl){
				
				// DO : 判断key值属否存在
				$key = $this->keyExist($mergeArr, $key);
				$mergeArr[$key] = $imageColl;
			}
			krsort($mergeArr);
			$mergeArr = array_slice($mergeArr, 0,$returnCount);
		}else{
			$mergeArr = $articles;
		}
		$mergeArr = array_values($mergeArr);
		return $mergeArr;
		
	}
	
	private function keyExist($mergeArr,$key){

		if(array_key_exists($key,$mergeArr)){
			$key = $key - 1;
		}
		return $key;
		
	}
	/**
	 * 处理控件传过来的标签Id
	 * @param : String $conditionTagId 查询条件的标签ID
	 */
	public function parseTagId($conditionTagId,$topTagId = ''){
		if(mb_substr_count($conditionTagId,',') || mb_substr_count($conditionTagId,'，')){
			$conditionTagId = str_replace('，', ',', $conditionTagId);
			$this->conditionTagId = explode(',',$conditionTagId);
		}else{
			$this->conditionTagId = $conditionTagId;
		}
		if($topTagId){
			if(mb_substr_count($topTagId,',') || mb_substr_count($topTagId,'，')){
				$topTagId = str_replace('，', ',', $topTagId);
				$this->topTagId = explode(',',$topTagId);
			}else{
				$this->topTagId = $topTagId;
			}	
		}
	}
	private function packQueryCondition($queryCondition){

		if(isset($queryCondition['isPrimaryTag'])){
			$isPrimaryTag = $queryCondition['isPrimaryTag'];
		}else{
			$isPrimaryTag = false;
		}
		if(isset($queryCondition['isReturnTag'])){
			$isReturnTag = $queryCondition['isReturnTag'];
		}else{
			$isReturnTag = false;
		}
		
		if(!isset($queryCondition['isParentTag'])){
			$isParentTag = true;
		}else{
			$isParentTag = $queryCondition['isParentTag'];
		}
		if(!isset($queryCondition['isConditionTag'])){
			$isConditionTag = true;
		}else{
			$isConditionTag = $queryCondition['isConditionTag'];
		}
		if(!isset($queryCondition['isReturnPrimary'])){
		    $isReturnPrimary = true;
		}else{
		    $isReturnPrimary = $queryCondition['isReturnPrimary'];
		}
		
		return array($isPrimaryTag,$isReturnTag,$isParentTag,$isConditionTag,$isReturnPrimary);
	}
	
	private static function getHash($key,$isNew = true){
		$hash = crc32($key) >> 16 & 0xffff;
		$cdnHostArr = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_CDN_HOST);
		if(!$isNew){
			$cdnHostArr = \haibao\cms\Config::$cdnHost;
		}
		return sprintf('%01s',$hash % count($cdnHostArr));
	}
	
	public function initTag(){
		$this->conditionTagId = 0;
		$this->topTagId = 6;
	}
	
	
	/**
	 * 综合数据解析
	 */
	public function parseMultiData($multiDatas,$manualData){
		$multiDataType = $this->getMultiDataType();
		if(isset($manualData['multiDataType'])){
			$manualData['multiDataType'] = explode(',',$manualData['multiDataType']);
			$multiDataType = $manualData['multiDataType'];
		}
		if(!isset($manualData['proLevel'])) {
			$manualData['proLevel'] = \haibao\cms\model\data\ArticleProImage::Level_FIVE;
		}
		$multiDataArr = array();
		foreach($multiDatas as $data){
			array_push($multiDataArr,json_decode($data['ParameterValue'],true));
		}
		$dataArr = array();
		foreach($multiDataArr as $key=>$arr){
			
			if(isset($arr['multiData'])){
				$exArr  = explode(',',$arr['multiData']);
				if(isset($exArr[0]) && isset($exArr[1]) ) {
					if(in_array($exArr[1],$multiDataType)){
						if(!isset($arr['title'])) $arr['title'] = '';
						if(!isset($arr['imageUrl'])) $arr['imageUrl'] = '';
						$this->getAutoData($exArr[0],$exArr[1],$manualData['proLevel'],$arr['title'],$arr['imageUrl']);
					}
				}
			}
		}
		$this->packageArrCount = count($this->packageArr);
	}
	
	public function getAutoData($id,$type,$proLevel,$title = '',$imageUrl = ''){
		$finalArr = array();
		switch($type){
			// \haibao\cms\web\ajax\Cart::DATA_TYPE_ARTICLE:
			case self::DATA_TYPE_ARTICLE:
				$articleFilter = new ArticleFilter();
				$articleTagFilter = new ArticleTagFilter();
				$articleProImageFitler = new ArticleProImageFilter();
				$articleFilter->select(
						array(
								ArticleFilter::CONDITION_FIELD_NAME_ID,
								ArticleFilter::CONDITION_FIELD_NAME_SHORTTITLE,
								ArticleFilter::CONDITION_FIELD_NAME_PUBLISHTIME,
								ArticleFilter::CONDITION_FIELD_NAME_ARTICLE_PUBLISHID,
								ArticleFilter::CONDITION_FIELD_NAME_TITLE,
								ArticleFilter::CONDITION_FIELD_NAME_SITETYPE,
						)
				);
				$articleProImageFitler->select(
						array(
								ArticleProImageFilter::CONDITION_FIELD_NAME_PIC_URL,
								ArticleProImageFilter::CONDITION_FIELD_NAME_LEVEL,
								ArticleProImageFilter::CONDITION_FIELD_NAME_ARTICLE_ID,
						)
				);
				$articleTagFilter->select(
						array(
								ArticleTagFilter::CONDITION_FIELD_NAME_PARENT_ID,
								ArticleTagFilter::CONDITION_FIELD_NAME_IS_PRIMAIY,
								ArticleTagFilter::CONDITION_FIELD_NAME_TAG_ID,
								ArticleTagFilter::CONDITION_FIELD_NAME_ARTICLE_ID,
						)
				);
				
				$articleFilter->where(ArticleFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_EQUAL,$id);
				$articleFilter->where(ArticleFilter::CONDITION_FIELD_NAME_PUBLISHED,Condition::CONDITION_EQUAL,\haibao\cms\model\data\Article::PUBLISHED_YES);
				$articleTagFilter->where(ArticleTagFilter::CONDITION_FIELD_NAME_IS_PRIMAIY,Condition::CONDITION_EQUAL,\haibao\cms\model\data\ArticleTag::PRIMAIY_IS);
				if(gettype($proLevel) == 'string'){
				    if(gettype($proLevel) == 'string'){
				        $proLevel = explode(',',$proLevel);
				        array_push($proLevel,\haibao\cms\model\data\ArticleProImage::Level_ZERO);
				    }
				    $articleProImageFitler->where(ArticleProImageFilter::CONDITION_FIELD_NAME_LEVEL,Condition::CONDITION_IN,$proLevel);
				}else{
				    $articleProImageFitler->where(ArticleProImageFilter::CONDITION_FIELD_NAME_LEVEL,Condition::CONDITION_IN,array(\haibao\cms\model\data\ArticleProImage::Level_ZERO,$proLevel));
				}
				$articleProImageFitler->where(ArticleProImageFilter::CONDITION_FIELD_NAME_PIC_TYPE,Condition::CONDITION_EQUAL,\haibao\cms\model\data\ArticleProImage::PIC_TYPE_INTRO);
				$articleFilter->leftJoin($articleProImageFitler,null,ArticleFilter::CONDITION_FIELD_NAME_ID,ArticleProImageFilter::CONDITION_FIELD_NAME_ARTICLE_ID,ArticleFilter::CONDITION_FIELD_NAME_ARTICLE_PRO_IMAGE);
				$articleFilter->leftJoin($articleTagFilter,null,ArticleFilter::CONDITION_FIELD_NAME_ID,ArticleTagFilter::CONDITION_FIELD_NAME_ARTICLE_ID,ArticleFilter::CONDITION_FIELD_NAME_ARTICLE_TAG,false);
	
				$article = \haibao\cms\business\Article::getArticleModel($articleFilter);
				if($article && $article->ArticleProImage && $article->ArticleTag){
					$proImage = array();
					foreach($article->ArticleProImage as $image){
						$proImage[$image->Level] = $image->toArray();
					}
					if(is_array($proLevel)){
						$article->ArticleProImage = $proImage;
					}else{
					    if(isset($proImage[$proLevel])){
					        $article->ArticleProImage = $proImage[$proLevel]['PicUrl'];
					    }else{
					        if(isset($proImage[\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
					            $article->ArticleProImage = $proImage[\haibao\cms\model\data\ArticleProImage::Level_ZERO]['PicUrl'];
					        }else{
					            $article->ArticleProImage = '';
					        }
					    }
					}
					if($imageUrl) $article->ArticleProImage = $imageUrl;
					$this->packageKey = strtotime($article->PublishTime->format('Y-m-d H:i:s'))+$article->Id;
					$tagId = 0;
					if($article->ArticleTag->TagId){
						$tagId = $article->ArticleTag->TagId;
					}
					$article->SiteType = $type;
					if($title) {
						$article->ShortTitle = $title;
					}
					$this->packageArr($type,$article,false);
				}
				break;
			case self::DATA_TYPE_IMAGE_SET:
				$imageCollFilter = new ImageCollFilter();
				$imageCollFilter->select(
						array(
								ImageCollFilter::CONDITION_FIELD_NAME_ID,
								ImageCollFilter::CONDITION_FIELD_NAME_TITLE,
								ImageCollFilter::CONDITION_FIELD_NAME_IMAGE_COLLECTIVE_PUBLISHTIME,
						)
				);
				$imageCollProFilter = new ImageCollProFilter();
				$imageCollProFilter->select(
						array(
								ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_ID,
								ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_IMAGE_TYPE,
						)
				);
	
				$imageCollTagFilter = new ImageCollTagFilter();
				$imageCollTagFilter->select(
						array(
								ImageCollTagFilter::CONDITION_FIELD_NAME_TAG_PARENTID,
								ImageCollTagFilter::CONDITION_FIELD_NAME_TAG_ISPRIMAIY,
								ImageCollTagFilter::CONDITION_FIELD_NAME_TAG_ID,
						)
				);
	
				$imageLibraryFilter = new ImageLibraryFilter();
				$imageLibraryFilter->select(
						array(
								ImageLibraryFilter::CONDITION_FIELD_NAME_FILENAME,
						)
				);
				$imageCollFilter->where(ImageCollFilter::CONDITION_FIELD_NAME_IMAGE_COLLECTIVE_PUBLISHED,Condition::CONDITION_EQUAL,\haibao\cms\model\data\imagecollective\ImageCollective::STATUS_YES_PUBLISH);
				$imageCollFilter->where(ImageCollFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_EQUAL,$id);
				
				if(gettype($proLevel) == 'string'){
				    if(gettype($proLevel) == 'string'){
				        $proLevel = explode(',',$proLevel);
				        array_push($proLevel,\haibao\cms\model\data\ArticleProImage::Level_ZERO);
				    }
				    $imageCollProFilter->where(ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_IMAGE_TYPE,Condition::CONDITION_IN,$proLevel);
				}else{
				    $imageCollProFilter->where(ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_IMAGE_TYPE,Condition::CONDITION_IN,array($proLevel,\haibao\cms\model\data\imagecollective\ImageCollectivePro::IMAGE_TYPE_ZERO));
				}
				$imageCollTagFilter->where(ImageCollTagFilter::CONDITION_FIELD_NAME_TAG_ISPRIMAIY,Condition::CONDITION_EQUAL,\haibao\cms\model\data\imagecollective\ImageCollectiveTag::IS_PRIMAIY);
				$imageCollFilter->leftJoin($imageCollProFilter,null,ImageCollFilter::CONDITION_FIELD_NAME_ID,ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_COLLECTIVE_ID,ImageCollFilter::CONDITION_FIELD_NAME_IMAGE_COLLECTIVE_PRO);
				$imageCollFilter->leftJoin($imageLibraryFilter,$imageCollProFilter,ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_ID,ImageLibraryFilter::CONDITION_FIELD_NAME_ID,ImageCollProFilter::CONDITION_FIELD_NAME_IMAGE_FILENAME,false);
				$imageCollFilter->leftJoin($imageCollTagFilter,null,ImageCollFilter::CONDITION_FIELD_NAME_ID,ImageCollTagFilter::CONDITION_FIELD_NAME_TAG_COLLECTIVE_ID,ImageCollFilter::CONDITION_FIELD_NAME_IMAGE_COLLECTIVE_TAG,false);
	
				$data = new \haibao\cms\data\imagecollective\ImageCollective();
				$imageColl = $data->getOne($imageCollFilter);
				$proUrl = '';
				if($imageColl && $imageColl->ImageCollectivePro){
					
					$proImage = array();
					foreach($imageColl->ImageCollectivePro as $image){
						$proImage[$image->ImageType] = $image->FileName->toArray();
					}
					if(is_array($proLevel)){
					    $imageColl->ImageCollectivePro = $proImage;
					}else{
					    if(isset($proImage[$proLevel])){
					        $imageColl->ImageCollectivePro = $proImage[$proLevel]['Filename'];
					    }else{
					        if(isset($proImage[\haibao\cms\model\data\imagecollective\ImageCollectivePro::IMAGE_TYPE_ZERO])){
					            $imageColl->ImageCollectivePro = $proImage[\haibao\cms\model\data\imagecollective\ImageCollectivePro::IMAGE_TYPE_ZERO]['Filename'];
					        }else{
					            $imageColl->ImageCollectivePro = '';
					        }
					    }
					}
					
	
					if(!$imageColl->PublishTime) $imageColl->PublishTime = new \DateTime();
					$this->packageKey = strtotime($imageColl->PublishTime->format('Y-m-d H:i:s'))+$imageColl->Id;
					if($title) $imageColl->ShortTitle = $title;
					$this->packageArr($type,$imageColl,false);
				}
				break;
			case self::DATA_TYPE_FEATURE:
				
				$featureFilter = new FeaturePublishFilter();
				$featureFilter->select(
						array(
								FeaturePublishFilter::CONDITION_FIELD_NAME_ID,
								FeaturePublishFilter::CONDITION_FIELD_NAME_FEATURE_NAME,
								FeaturePublishFilter::CONDITION_FIELD_NAME_PUBLISH_TIME,
								FeaturePublishFilter::CONDITION_FIELD_NAME_PICTURE_ID,
								FeaturePublishFilter::CONDITION_FIELD_NAME_URL,
						)
				);
				
				$featureTagFilter = new FeatureTagFilter();
				$featureTagFilter->select(array(FeatureTagFilter::CONDITION_FIELD_NAME_TAG_ID));
				
				$defineFilter = new \haibao\cms\model\filter\FeatureDefine();
				$defineFilter->select(array(
						\haibao\cms\model\filter\FeatureDefine::CONDITION_FIELD_NAME_ID,
						\haibao\cms\model\filter\FeatureDefine::CONDITION_FIELD_NAME_FEATURE_NAME,
						\haibao\cms\model\filter\FeatureDefine::CONDITION_FIELD_NAME_DESCRIPTION,
				));
				$featureFilter->innerJoin(
						$defineFilter,
						null,
						\haibao\cms\model\filter\FeaturePublish::CONDITION_FIELD_NAME_FEATURE_DEFINE_ID,
						\haibao\cms\model\filter\FeatureDefine::CONDITION_FIELD_NAME_ID,
						\haibao\cms\model\filter\FeaturePublish::CONDITION_FIELD_NAME_FEATURE_DEFINE,
						false
				);
				
				if(!$imageUrl){
					$imageLibraryFilter = new ImageLibraryFilter();
					$imageLibraryFilter->select(
							array(
									ImageLibraryFilter::CONDITION_FIELD_NAME_FILENAME,
							)
					);
					$featureFilter->leftJoin($imageLibraryFilter,null,FeaturePublishFilter::CONDITION_FIELD_NAME_PICTURE_ID,ImageLibraryFilter::CONDITION_FIELD_NAME_ID,FeaturePublishFilter::CONDITION_FIELD_NAME_IMAGE,false);
				}
				$featureFilter->limit(0,1);
				$featureFilter->order(FeatureTagFilter::CONDITION_FIELD_NAME_ID,true,$featureTagFilter);
				$featureFilter->leftJoin($featureTagFilter,null,FeaturePublishFilter::CONDITION_FIELD_NAME_ID,FeatureTagFilter::CONDITION_FIELD_NAME_FEATURE_ID,FeaturePublishFilter::CONDITION_FIELD_NAME_TAGS,false);
				$featureFilter->where(FeaturePublishFilter::CONDITION_FIELD_NAME_STATUS,Condition::CONDITION_EQUAL,\haibao\cms\model\data\FeaturePublish::STATUS_PUBLISH);
				$featureFilter->where(FeaturePublishFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_EQUAL,$id);
				$data = new \haibao\cms\data\FeaturePublish();
				$feature = $data->getOne($featureFilter);
				if($feature){
					if($imageUrl){
						$feature->Pic = $imageUrl;
					}else{
						if ($feature->PictureId){
							$feature->Pic = $feature->Image->Filename;
						}else{
							$feature->Pic = '';
						}
					}
					$this->packageKey = strtotime($feature->PublishTime->format('Y-m-d H:i:s'))+$feature->Id;

					if($title) $feature->FeatureDefine->FeatureName = $title;
					$this->packageArr($type,$feature,false);
	
				}
				break;
			case self::DATA_TYPE_VIDEO:
				$videoFilter = new VideoFilter();
				$videoFilter->select(
						array(
								VideoFilter::CONDITION_FIELD_NAME_ID,
								VideoFilter::CONDITION_FIELD_NAME_TITLE,
								VideoFilter::CONDITION_FIELD_NAME_PUBLISHDATE
						)
				);
				$imageLibraryFilter = new ImageLibraryFilter();
				$imageLibraryFilter->select(
						array(
								ImageLibraryFilter::CONDITION_FIELD_NAME_FILENAME,
						)
				);
				$videoFilter->where(VideoFilter::CONDITION_FIELD_NAME_ID,Condition::CONDITION_EQUAL,$id);
				$videoFilter->leftJoin($imageLibraryFilter,null,VideoFilter::CONDITION_FIELD_NAME_PICID,ImageLibraryFilter::CONDITION_FIELD_NAME_ID,VideoFilter::CONDITION_FIELD_NAME_PIC_URL,false);
	
				$data = new \haibao\cms\data\Video();
				$video = $data->getOne($videoFilter);
				if($video && $video->PicUrl->Filename){
					$this->packageKey = strtotime($video->PublishDate->format('Y-m-d H:i:s'))+$video->Id;
					$video->VideoUrl = \haibao\classlibrary\cms\Config::getConfig(\haibao\classlibrary\cms\Config::CLASSLIBRARY_CONFIG_HOST_EXCLUSIVE).'/play/'.$video->Id.'.htm';
					if($title) $video->Title = $title;
					if($imageUrl) $video->PicUrl->Filename = $imageUrl;
					$this->packageArr($type,$video,true);
				}
				break;
			case self::DATA_TYPE_IMAGE_EXCLUSIVE:
				$exclusiveFilter = new \haibao\cms\model\filter\ExclusiveDefine();
				$exclusiveFilter->select(array(
						\haibao\cms\model\filter\ExclusiveDefine::CONDITION_FIELD_NAME_ID,
						\haibao\cms\model\filter\ExclusiveDefine::CONDITION_FIELD_NAME_EXCLUSIVENAME,
						\haibao\cms\model\filter\ExclusiveDefine::CONDITION_FIELD_NAME_EXCLUSIVEURL,
						\haibao\cms\model\filter\ExclusiveDefine::CONDITION_FIELD_NAME_PICURL,
						\haibao\cms\model\filter\ExclusiveDefine::CONDITION_FIELD_NAME_CREATETIME
				));
				$exclusiveFilter->where(\haibao\cms\model\filter\ExclusiveDefine::CONDITION_FIELD_NAME_ID,Condition::CONDITION_EQUAL,$id);
				$data = new \haibao\cms\data\ExclusiveDefine();
				$exclusive = $data->getOne($exclusiveFilter);
				if($exclusive){
					$this->packageKey = strtotime($exclusive->CreateTime->format('Y-m-d H:i:s'))+$exclusive->Id;
					$this->packageArr($type,$exclusive);
				}
				break;
			default:
				break;
		}
	}
	
	/**
	 * 处理编辑手动上传的博主资讯
	 */
	public function getBlogCustomData($blogdata){
		$parameters = array();
		foreach($blogdata as $data){
		
			$parameterValue = json_decode($data['ParameterValue'],true);
		
			if(isset($parameterValue['blogUrl'])){
				//http://fashionista.haibao.com/blog/43157.htm
				if(preg_match('/(.*)\/(\d+)\.htm/i', $parameterValue['blogUrl'], $match)){
		
					if(isset($match[2])){
						$blogId = $match[2];
						$parameters[$blogId]['blogUrl'] = $parameterValue['blogUrl'];
						$parameters[$blogId]['blogTitle'] = $parameters[$blogId]['blogShortTitle'] = '';
						$parameters[$blogId]['blogCateId'] = $parameters[$blogId]['blogCateId'] = '';
						if(isset($parameterValue['blogTitle'])) $parameters[$blogId]['blogTitle'] = $parameterValue['blogTitle'];
						if(isset($parameterValue['blogShortTitle'])) $parameters[$blogId]['blogShortTitle'] = $parameterValue['blogShortTitle'];
						if(isset($parameterValue['blogCateId'])) $parameters[$blogId]['blogCateId'] = $parameterValue['blogCateId'];
		
					}
				}
			}
		}
		return $parameters;
	}
	
	/**
	 * 手动数据替换广告位
	 */
	public function replaceAdPosition($autoData,$isTest = false){
		$showAutoData = false;
		$parameterValue = array();
		if($autoData){
			$showAutoData = true;
			foreach($autoData as $data){
				$parameterValue = json_decode($data['ParameterValue']);
			}
		}
		if($isTest){
		}
		$this->assign('parameterValue',$parameterValue);
		$this->assign('showAutoData',$showAutoData);
		
	}
	
	/**
	 * 得APP文章题图URL
	 * @param unknown_type $artilceId
	 * @return Ambigous <string, mixed>
	 */
	private function getArticleImage($artilceId){
		$picUrl = '';
		$imageId = \haibao\app\business\Article::getArticleImageId($artilceId);
		if($imageId){
			$fileNames = \haibao\cms\business\ImageLibrary::getImageUrlById($imageId);
			if($fileNames){
				$picUrl = self::getImageLink($fileNames[$imageId],750,530,100,0,true);
			}
		}
		
		return $picUrl;
	}
	
	/**
	 * 封装混合数据
	 */
	public function packageMergeData($type,$mergeData,$articles,$imageColls){

		$firstLeftArticle = $firstRightArticle = array();
		// trend/star
		if($type == self::PACKAGE_DATA_TYPE_INDEX_TREND_OR_STAR){
			foreach($mergeData as $key=>$article){
				switch($key){
					case 0:
					case 3:
					case 4:
					case 5:
					case 6:
						$firstLeftArticle[$key] = $article->toArray();
						if($article->SiteType == ArticleController::INFO_TYPE_ARTICLE){
			
							$tagList = $articles['tag'];
							$articleTags = $articles['articleTag'];
							$firstLeftArticle[$key]['PublishTime'] = $this->formatDate($article->PublishTime->format('Y-m-d H:i:s'));
							$firstLeftArticle[$key]['Channel'] = self::getArticleUrl($article->PublishId,$articleTags[$article->Id]['ParentId']);
							$firstLeftArticle[$key]['TagName'] = $tagList[$articleTags[$article->Id]['TagId']]['TagName'];
							$firstLeftArticle[$key]['TagUrl'] = $tagList[$articleTags[$article->Id]['TagId']]['Url'];
			
							if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FIVE])){
								$firstLeftArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FIVE];
							}else{
								if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstLeftArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstLeftArticle[$key]['ProImage'] = '';
								}
							}
						}else{
							$tagList = $imageColls['tag'];
							$collTags = $imageColls['collTag'];
							$firstLeftArticle[$key]['PublishTime'] = $this->formatDate($article->PublishTime->format('Y-m-d H:i:s'));
							$firstLeftArticle[$key]['Channel'] = self::getArticleUrl($article->Id,$collTags[$article->Id]['ParentId'],ArticleController::INFO_TYPE_IMAGE);
							$firstLeftArticle[$key]['TagName'] = $tagList[$collTags[$article->Id]['TagId']]['TagName'];
							$firstLeftArticle[$key]['TagUrl'] = $tagList[$collTags[$article->Id]['TagId']]['Url'];
							$firstLeftArticle[$key]['SiteType'] = $article->SiteType;
			
							if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FIVE])){
								$firstLeftArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FIVE];
							}else{
								if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstLeftArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstLeftArticle[$key]['ProImage'] = '';
								}
							}
						}
							
						break;
					case 1:
					case 2:
						$firstRightArticle[$key] = $article->toArray();
						if($article->SiteType == ArticleController::INFO_TYPE_ARTICLE){
			
							$tagList = $articles['tag'];
							$articleTags = $articles['articleTag'];
			
							$firstRightArticle[$key]['Channel'] = self::getArticleUrl($article->PublishId,$articleTags[$article->Id]['ParentId']);
							$firstRightArticle[$key]['Title'] = $article->Title;
							$firstRightArticle[$key]['ShortTitle'] =$article->ShortTitle;
							$firstRightArticle[$key]['TagName'] = $tagList[$articleTags[$article->Id]['TagId']]['TagName'];
							$firstRightArticle[$key]['TagUrl'] = $tagList[$articleTags[$article->Id]['TagId']]['Url'];
							
							if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_SEVEN])){
								$firstRightArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_SEVEN];
							}else{
								if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstRightArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstRightArticle[$key]['ProImage'] = '';
								}
							}
						}else{
			
							$tagList = $imageColls['tag'];
							$collTags = $imageColls['collTag'];
			
							$firstRightArticle[$key]['Channel'] = self::getArticleUrl($article->Id,$collTags[$article->Id]['ParentId'],ArticleController::INFO_TYPE_IMAGE);
							$firstRightArticle[$key]['Title'] = $article->Title;
							$firstRightArticle[$key]['ShortTitle'] = $article->ShortTitle;
							$firstRightArticle[$key]['SiteType'] = $article->SiteType;
							$firstRightArticle[$key]['TagName'] = $tagList[$collTags[$article->Id]['TagId']]['TagName'];
							$firstRightArticle[$key]['TagUrl'] = $tagList[$collTags[$article->Id]['TagId']]['Url'];
							if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_SEVEN])){
								$firstRightArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_SEVEN];
							}else{
								if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstRightArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstRightArticle[$key]['ProImage'] = '';
								}
							}
						}
						break;
					default:
						break;
				}
			}
		// brand/beauty/life
		}elseif($type == self::PACKAGE_DATA_TYPE_INDEX_BRAND_OR_BEAUTY_OR_LIFT){
			foreach($mergeData as $key=>$article){
				switch($key){
					case 0:
					case 3:
					case 4:
					case 5:
					case 6:
						$firstLeftArticle[$key] = $article->toArray();
						if($article->SiteType == ArticleController::INFO_TYPE_ARTICLE){
			
							$tagList = $articles['tag'];
							$articleTags = $articles['articleTag'];
			
							$firstLeftArticle[$key]['PublishTime'] = $this->formatDate($article->PublishTime->format('Y-m-d H:i:s'));
							$firstLeftArticle[$key]['Channel'] = self::getArticleUrl($article->PublishId,$articleTags[$article->Id]['ParentId']);
							$firstLeftArticle[$key]['TagName'] = $tagList[$articleTags[$article->Id]['TagId']]['TagName'];
							$firstLeftArticle[$key]['TagUrl'] = $tagList[$articleTags[$article->Id]['TagId']]['Url'];
			
							if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR])){
								$firstLeftArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR];
							}else{
								if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstLeftArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstLeftArticle[$key]['ProImage'] = '';
								}
							}
						}else{
							$tagList = $imageColls['tag'];
							$collTags = $imageColls['collTag'];
							$firstLeftArticle[$key]['PublishTime'] = $this->formatDate($article->PublishTime->format('Y-m-d H:i:s'));
							$firstLeftArticle[$key]['Channel'] = self::getArticleUrl($article->Id,$collTags[$article->Id]['ParentId'],ArticleController::INFO_TYPE_IMAGE);
							$firstLeftArticle[$key]['TagName'] = $tagList[$collTags[$article->Id]['TagId']]['TagName'];
							$firstLeftArticle[$key]['TagUrl'] = $tagList[$collTags[$article->Id]['TagId']]['Url'];
							$firstLeftArticle[$key]['SiteType'] = $article->SiteType;
			
							if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR])){
								$firstLeftArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR];
							}else{
								if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstLeftArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstLeftArticle[$key]['ProImage'] = '';
								}
							}
						}
							
						break;
					default:
						$firstRightArticle[$key] = $article->toArray();
						if($article->SiteType == ArticleController::INFO_TYPE_ARTICLE){
							$tagList = $articles['tag'];
							$articleTags = $articles['articleTag'];
							$firstRightArticle[$key]['Channel'] = self::getArticleUrl($article->PublishId,$articleTags[$article->Id]['ParentId']);
							$firstRightArticle[$key]['Title'] = $article->Title;
							$firstRightArticle[$key]['ShortTitle'] =$article->ShortTitle;
							$firstRightArticle[$key]['TagName'] = $tagList[$articleTags[$article->Id]['TagId']]['TagName'];
							$firstRightArticle[$key]['TagUrl'] = $tagList[$articleTags[$article->Id]['TagId']]['Url'];
							
							if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR])){
								$firstRightArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR];
							}else{
								if(isset($articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstRightArticle[$key]['ProImage'] = $articles['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstRightArticle[$key]['ProImage'] = '';
								}
							}
						}else{
			
							$tagList = $imageColls['tag'];
							$collTags = $imageColls['collTag'];
							$firstRightArticle[$key]['Channel'] = self::getArticleUrl($article->Id,$collTags[$article->Id]['ParentId'],ArticleController::INFO_TYPE_IMAGE);
							$firstRightArticle[$key]['Title'] = $article->Title;
							$firstRightArticle[$key]['ShortTitle'] = $article->ShortTitle;
							$firstRightArticle[$key]['SiteType'] = $article->SiteType;
							$firstRightArticle[$key]['TagName'] = $tagList[$collTags[$article->Id]['TagId']]['TagName'];
							$firstRightArticle[$key]['TagUrl'] = $tagList[$collTags[$article->Id]['TagId']]['Url'];
							if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR])){
								$firstRightArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_FOUR];
							}else{
								if(isset($imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO])){
									$firstRightArticle[$key]['ProImage'] = $imageColls['proImage'][$article->Id][\haibao\cms\model\data\ArticleProImage::Level_ZERO];
								}else{
									$firstRightArticle[$key]['ProImage'] = '';
								}
							}
						}
						break;
				}
			}	
		}
		return array($firstLeftArticle,$firstRightArticle);
	}
	/**
	 * 封装数组
	 * @param Int $type
	 * @param Int $id
	 * @param String $title
	 * @param String $picUrl
	 * @param Boolure $isVideo
	 */
	private function packageArr($type,$entity,$isVideo = false){
		$temp = array();
		$temp ['Type'] = $type;
		$temp ['Entity'] = $entity;
		$temp ['IsVideo'] = $isVideo;
		$this->packageArr[$this->packageKey] = $temp;
	}
	
	/**
	 * 获取综合数据类型
	 */
	private function getMultiDataType(){
		return array(
				self::DATA_TYPE_ARTICLE,
				self::DATA_TYPE_IMAGE_SET,
				self::DATA_TYPE_FEATURE,
				self::DATA_TYPE_VIDEO,
				self::DATA_TYPE_VIDEO,
				self::DATA_TYPE_IMAGE_EXCLUSIVE
		);
	}
	
	public function getIncludeCn($NameEn){
	    $isIncludeCn = false;
	    $pattern = '/[^\x00-\x80]/';
	    if($NameEn){
	        if(preg_match($pattern,$NameEn)){
	            $isIncludeCn = true;
	        }
	    }
	    return $isIncludeCn;
	}
	
	public function getRepeatName($NameCn,$NameEn){
	    $isRepeatName = false;
	    if($NameCn && $NameEn){
	        if($NameCn == $NameEn){
	            $isRepeatName = true;
	        }
	    }
	    return $isRepeatName;
	}
	
	public function savaLog(){
		$path = Environment::path().'/web/logs/publish.log';
		if(file_exists($path)){
			file_put_contents($path,'--'.get_class($this)."--\n",FILE_APPEND);
		}
	}
	
}

